<?php
header ('Content-type: text/html; charset=utf-8');
if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl = 'admin.php?ac=expert';
$list = array();
if ($_GET ['op'] == "removeExpert") {
    // 日记详情
    $uid = intval($_GET ['uid']);
    $param['uid']    =    $uid;
    $param['do']     =    'removeExpert';
    $param['format'] =    'json';
       
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);

    if ($content->resultData == 1) {
        $msg = "操作成功!";
        cpmessage($msg);
    }
    $msg = "操作失败，请重试一次!";
    if ($content->errorNo) {
        $msg .= "errorNo:" . $content->errorNo;
    }
    cpmessage($msg);
    // 搜索
}elseif ($_GET['op'] == 'addExpert') {
    $uid 	= intval($_GET['uid']);
    $param  = array(
            'do' 		=> 'addExpertInfo',
            'format'	=> 'json',
            'uid' 		=> $uid,
    );

    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    if ($content->resultData == 1) {
        $msg = "操作成功!";
        cpmessage($msg);
    }
    $msg = "操作失败，请重试一次!";
    if ($content->errorNo) {
        $msg .= "errorNo:" . $content->errorNo;
    }
    cpmessage($msg);
    
}else {
    $start              = intval($_GET ['start']) > 1 ? intval($_GET ['start']) : 0;
    $uid 	            = intval($_GET ['uid']);
    $length             = intval($_GET ['length']) > 0 ? intval($_GET ['length']) : 20;
    $order              = $_GET['order'];
    // 搜索申请中的达人列表
    $param  = array(
            'do' 		=> 'getExpertList',
            'format'	=> 'json',
            'start'     => $start,
            'length'    => $length,
    );
    
    !empty($uid)            && $param['uid']    =    $uid;
    !empty($order)          && $param['order']  =   $order;
    
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    $list = object_to_array($content->resultData);
    
    $mpurl  = 'admin.php?ac=expert&op=getExpertList';
    $pageurl = multi($start, $length, $mpurl);
    $nextpurl = $pageurl ['next'];
    $prevpurl = $pageurl ['prev'];
    $mpurl    = $pageurl ['urls'];
    $firstpurl = $pageurl ['first'];
    
    $perpages = array(
            $perpage => ' selected'
    );
    include_once template("admin/expert");
    exit;
}



